#include "StdAfx.h"
#include "SAPIEventCallback.h"
#include "sphelper.h"
//#include <iostream>
//#include "time.h"

SAPIEventCallbackImpl::SAPIEventCallbackImpl(void)
{
	owner = NULL;
	pVoice = NULL;
	refCount = 0;
}

SAPIEventCallbackImpl::~SAPIEventCallbackImpl(void)
{
}

HRESULT SAPIEventCallbackImpl::QueryInterface(const IID& riid, void** ppvObject)
{
	return S_FALSE;
}
ULONG SAPIEventCallbackImpl::AddRef()
{
	return ++refCount;
}
ULONG SAPIEventCallbackImpl::Release()
{
	return --refCount;
}

HRESULT SAPIEventCallbackImpl::Notify()
{
	CSpEvent eventHelper;
	HRESULT hr = eventHelper.GetFrom(pVoice);
	if(SUCCEEDED(hr) && owner)
	{
		owner->NotifySAPIEventCallback((CSpEvent*)&eventHelper);
	}
	return S_OK;
}

/*
	SPPHONEID phoneId;
	std::wstring str;
	if(SUCCEEDED(hr))
	{		
		if(eventHelper.elParamType==SPET_LPARAM_IS_STRING)
		{
			const WCHAR* tmp = eventHelper.String();
			str.assign(tmp);
		}

		switch(eventHelper.eEventId)
		{
		case SPEI_START_INPUT_STREAM:
			lastPos = 0;
			break;
		case SPEI_PHONEME:
			//if(!inputStartedTime)
			{
				//inputStartedTime = clock();
			}
			//phoneId = eventHelper.Phoneme();
			break;
		case SPEI_VISEME:
			//if(!inputStartedTime)
			{
				//inputStartedTime = clock();
			}
			//phoneId = eventHelper.Phoneme();
			break;
		case SPEI_WORD_BOUNDARY:
			//if(!inputStartedTime)
			{
				//inputStartedTime = clock();
			}
			break;
		case SPEI_END_INPUT_STREAM:
			//stopTime = clock();
			//done = true;
			break;
		default:
			//std::cout << eventHelper.eEventId << std::endl;
			break;
		}
	}
	return S_OK;
}
*/
